package com.atguigu01.collection;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collection;

public class CollectionTest {


    @Test
    public void test1() {
        //add()
        Collection list = new ArrayList<>();
        list.add("AA");
        list.add(123);//自动装箱
        list.add(new Object());
        list.add(new Person("TOM",22));

        System.out.println(list);


        //addAll()
        Collection list2 = new ArrayList<>();
        list2.add(234);
        list2.add("BB");

//        list.addAll(list2);//size为6
        list.add(list2);

        System.out.println(list.size());
    }


    @Test
    public void test2() {
        //add()
        Collection list = new ArrayList<>();
        list.add("AA");
        list.add(128);//自动装箱
        list.add(new Person("TOM",22));

        System.out.println(list.isEmpty());

        //contains() 方法
        System.out.println(list.contains("AA"));
        System.out.println(list.contains(128));
        System.out.println(list.contains(new Person("TOM",22)));//底层是用的equals方法，自定义对象需要重写equals方法s
    }

}
